/***********************************************************************************************************************************
 * Name: Cleanup.sql
 * Author: Frank Figearo (frank.figearo@us.bbaaviation.com|frank@sqlnerd.me)
 * Summary: When trying to *ADD* an article, you get this error:
 *	Msg 14046, Level 16, State 1, Procedure sp_MSdrop_article, Line 75
 *	Could not drop article. A subscription exists on it.
 */
SET IMPLICIT_TRANSACTIONS OFF; IF 0 < @@TRANCOUNT ROLLBACK;
USE DistributionDB
GO
DECLARE @tsql NVARCHAR(MAX) = 'DELETE FROM MSSubscriptions WHERE article_id IN (';
SELECT @tsql+= CAST(article_id AS VARCHAR)+',' FROM MSArticles WHERE source_owner = 'SigNetBRE'
SET @tsql+= ');'
SET @tsql= REPLACE(@tsql, ',);', ');')
EXECUTE @tsql;
GO